import { createRouter, createWebHistory } from 'vue-router'
import type {Router,RouteRecordRaw} from 'vue-router'
const HomeView = ()=>import('../views/HomeView.vue')
const NotFound = ()=>import('../views/NotFound.vue')

const routes:RouteRecordRaw[] = [
  {
    path: '/',
    redirect:'/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
]

const router:Router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes 
})

// router.beforeEach((to, from, next) => {
//   let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
//   if(!!flag && to.path=='/home'){
//       next('/notfound')
//   }else if(flag===null && to.path!=='/home'){
//     next('/home')
//   }else{
//     next()
//   }
// })

export default router
